//package com.choupin.choupin.interceptor;
//
//import com.choupin.choupin.utils.redis.RedisUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.CrossOrigin;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//
//public class LoginInterceptor implements HandlerInterceptor {
//
//    @Autowired
//    RedisUtils redisUtils;
//
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
////        先获取请求中用于获取redis中判断登录的phone
//       String phone=request.getParameter("phone");
//        System.out.println("获得值hpone："+phone);
////       在用phone组成redis的key获取其值
//        String rphone=redisUtils.getValue("phone:14357864579");
//        System.out.println("获得值rpone："+rphone);
//        // 如果为空则说明该账号登录已经失效需要从新登录
//        if (rphone==null){
//            System.out.println("该账号登录已经失效需要从新登录  ");
//            return false;
//        }else {
////            先调用redis的登录会话判断登陆是否失效或者是否登录
////        redisUtils.RedisLoginSession(phone);
////            再获取一次redis值判断是否为空，不为空则放行
////             rphone=redisUtils.getValue("phone:"+phone);
////            为空则登录失效
////        if (rphone==null){
////            System.out.println("该账号登录已经失效需要从新登录2");
////            return false;
////        }
////         return true;
////        }
//
//
////        System.out.println("先来到拦截器！");
////     HttpSession session=request.getSession();
////     String phone= (String) session.getAttribute("phone");
////        System.out.println("拦截器检测到："+phone);
////        if (phone==null){
////            request.getRequestDispatcher("http://localhost:8081/#/pages/login/login").forward(request,response);
////            System.out.println("phone:"+phone);
////            return  false;
////        }
////        return true;
//    }
//}
